﻿using System.Data.Entity;
using Autofac;
using Autofac.Integration.Mvc;
using TinyContactManager.Web.Internal.Data;

namespace TinyContactManager.Web.Internal.Modules
{
    public class DatabaseModule : Module
    {
        protected override void Load(ContainerBuilder builder)
        {
            Database.SetInitializer(new WorkflowEngineContextCreator());

            builder.RegisterType<ContactsEngineContext>()
                .AsSelf()
                .As<IDbContext>()
                .WithParameter("nameOrConnectionString", "DefaultConnection")
                .InstancePerHttpRequest();
        }
    }
}